
module sn76489_top(
  input  wire       clock_i,
  input  wire       clock_en_i,
  input  wire       res_n_i,
  input  wire       we_n_i,
  input  wire [7:0] d_i,
  output wire       ready_o,
  output wire [7:0] aout_o
);

wire       clk_en_s;
wire       tone1_we_s;
wire       tone2_we_s;
wire       tone3_we_s;
wire       noise_we_s;
wire       tone3_ff_s;
wire [7:0] tone1_s;
wire [7:0] tone2_s;
wire [7:0] tone3_s;
wire [7:0] noise_s;

sn76489_clock_div u_sn76489_clock_div(
	.clock_i    ( clock_i    ) ,
    .clock_en_i ( clock_en_i ) ,
	.res_n_i    ( res_n_i    ) ,
	.clk_en_o   ( clk_en_s   )
);

sn76489_latch_ctrl u_sn76489_latch_ctrl(
	.clock_i    ( clock_i    ) ,
	.clk_en_i   ( clk_en_s   ) ,
	.res_n_i    ( res_n_i    ) ,
	.we_n_i     ( we_n_i     ) ,
	.d_i        ( d_i        ) ,
	.ready_o    ( ready_o    ) ,
	.tone1_we_o ( tone1_we_s ) ,
	.tone2_we_o ( tone2_we_s ) ,
	.tone3_we_o ( tone3_we_s ) ,
	.noise_we_o ( noise_we_s ) ,
	.r2_o       ( r2_s       )
);

sn76489_tone u_sn76489_tone_1(
	.clock_i  ( clock_i    ) ,
	.clk_en_i ( clk_en_s   ) ,
	.res_n_i  ( res_n_i    ) ,
	.we_i     ( tone1_we_s ) ,
	.d_i      ( d_i        ) ,
	.r2_i     ( r2_s       ) ,
	.ff_o     (            ) ,
	.tone_o   ( tone1_s    )
);

sn76489_tone u_sn76489_tone_2(
	.clock_i  ( clock_i    ) ,
	.clk_en_i ( clk_en_s   ) ,
	.res_n_i  ( res_n_i    ) ,
	.we_i     ( tone2_we_s ) ,
	.d_i      ( d_i        ) ,
	.r2_i     ( r2_s       ) ,
	.ff_o     (            ) ,
	.tone_o   ( tone2_s    )
);

sn76489_tone u_sn76489_tone_3(
	.clock_i  ( clock_i    ) ,
	.clk_en_i ( clk_en_s   ) ,
	.res_n_i  ( res_n_i    ) ,
	.we_i     ( tone3_we_s ) ,
	.d_i      ( d_i        ) ,
	.r2_i     ( r2_s       ) ,
	.ff_o     ( tone3_ff_s ) ,
	.tone_o   ( tone3_s    )
);

sn76489_noise u_sn76489_noise(
	.clock_i    ( clock_i    ) ,
	.clk_en_i   ( clk_en_s   ) ,
	.res_n_i    ( res_n_i    ) ,
	.we_i       ( noise_we_s ) ,
	.d_i        ( d_i        ) ,
	.r2_i       ( r2_s       ) ,
	.tone3_ff_i ( tone3_ff_s ) ,
	.noise_o    ( noise_s    )
);

assign aout_o = tone1_s + tone2_s + tone3_s + noise_s;

endmodule
